


import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;

public class People extends Thread{
    protected CharacterControl character;
    protected Node model;
    protected int health;
    protected Node root;
    protected boolean dead;
    public People(Spatial mod, Node attaching){
        model = (Node) mod;
        CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
        character = new CharacterControl(capsuleShape, 0.05f);
        character.setJumpSpeed(20);
        character.setFallSpeed(30);
        character.setGravity(30);
        character.setPhysicsLocation(new Vector3f(0, 30f, 10f));
        model.addControl(character);
        health = 100;
        attaching.attachChild(model);
        root = attaching;
        dead = false;
    }
    public People(Spatial mod, Node attaching, Vector3f spawnpoint){
        model = (Node) mod;
        CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
        character = new CharacterControl(capsuleShape, 0.05f);
        character.setJumpSpeed(20);
        character.setFallSpeed(30);
        character.setGravity(30);
        character.setPhysicsLocation(spawnpoint);
        model.addControl(character);
        health = 100;
        attaching.attachChild(model);
        root = attaching;
    }
    public People(Spatial mod, Node attaching, Vector3f spawnpoint, CapsuleCollisionShape cap){
        model = (Node) mod;
        CapsuleCollisionShape capsuleShape = cap;
        character = new CharacterControl(capsuleShape, 0.05f);
        character.setJumpSpeed(20);
        character.setFallSpeed(30);
        character.setGravity(30);
        character.setPhysicsLocation(spawnpoint);
        model.addControl(character);
        health = 100;
        attaching.attachChild(model);
        root = attaching;
        dead = false;
    }
    public void checkDeath(){
        if(character.getPhysicsLocation().y <= -20 || health <= 0){
            character.setPhysicsLocation(new Vector3f(0f,30f,10f));
            health = 100;
        }
    }
    public void add(BulletAppState bulletAppState){
        character.setPhysicsLocation(new Vector3f(-140, 15, -10));
        bulletAppState.getPhysicsSpace().add(character); 
    }
    public Node getModel(){return model;}
    public Spatial getSpatialModel(){return (Spatial) model;}
    public CharacterControl getControl(){return character;}
    public Spatial getSpatial(){return (Spatial) model;}
    public void changeHealth(int change){health += change;}
    public int getHealth(){return health;}
    public void setHealth(int newhealth){health = newhealth;}
    public void setDeath(boolean bool){dead = bool;}
    public boolean getDeath(){return dead;}
    
}
